package com.service.impl;

import com.dao.RoleDao;
import com.pojo.SysRole;
import com.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    RoleDao roleDao;

    @Override
    public Set<String> findRolesByUserId(int uId) {
        List<SysRole> roleList = roleDao.findRolesByUserId(uId);

        Set<String> roles = roleList.stream().map((role) -> {
            return role.getName();
        }).collect(Collectors.toSet());

        return roles;
    }
}